<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateCatalogTable extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $catalog = $this->table('catalog', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '目录']);
        $catalog->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('name', 'string', ['default' => '', 'limit' => 255, 'comment' => '目录名称'])
            ->addColumn('item_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '项目ID'])
            ->addColumn('number', 'integer', ['limit' => 11, 'default' => 1, 'comment' => '序号'])
            ->addColumn('parent_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '父目录ID'])
            ->addColumn('level', 'integer', ['limit' => 10, 'default' => 2, 'comment' => '等级'])
            ->addColumn('last_update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('is_change','integer', ['signed' => false, 'default' => 0, 'limit' => 1, 'comment' => '权限状态'])
            ->save();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('catalog');
    }
}
